<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>SetEnv</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SetEnv (Var = Value)</h1>

<p>Assigns the specified value to a <a href="../Variables.htm">variable</a>.</p>

<pre class="Syntax">SetEnv, Var, Value
Var = Value</pre>
<h3>Parameters</h3>
<dl>

  <dt>Var</dt>
  <dd><p>The name of the <a href="../Variables.htm">variable</a> in which to store <em>Value</em>.</p></dd>

  <dt>Value</dt>
  <dd><p>The string or number to store. If the string is long, it can be broken up into several shorter lines by means of a <a href="../Scripts.htm#continuation">continuation section</a>, which might improve readability and maintainability.</p></dd>

</dl>

<h3>Remarks</h3>
<p>By default, any spaces or tabs at the beginning and end of <em>Value</em> are omitted from <em>Var</em>. To prevent this, use the methods described at <a href="AutoTrim.htm#Off">AutoTrim Off</a>.</p>
<p>The name &quot;SetEnv&quot; is misleading and is a holdover from AutoIt v2. Unlike AutoIt v2, AutoHotkey does not store its variables in the environment.  This is because performance would be worse and also because the OS limits the size of each environment variable to 32 KB. Use <a href="EnvSet.htm">EnvSet</a> instead of SetEnv to write to an <a href="../Variables.htm#env">environment variable</a>.</p>
<p>The memory occupied by a large variable can be freed by setting it equal to nothing, e.g. <code>Var =</code>.</p>
<p>It is possible to create a <a href="../misc/Arrays.htm#pseudo">pseudo-array</a> with this command and any others that accept an <em>OutputVar</em>. This is done by making <em>OuputVar</em> contain a reference to another variable, e.g. <code>array%i% = 123</code>. See <a href="../misc/Arrays.htm">Arrays</a> for more details.</p>
<h3>Related</h3>
<p><a href="AutoTrim.htm">AutoTrim</a>, <a href="EnvSet.htm">EnvSet</a>, <a href="EnvAdd.htm">EnvAdd</a>, <a href="EnvSub.htm">EnvSub</a>, <a href="EnvMult.htm">EnvMult</a>, <a href="EnvDiv.htm">EnvDiv</a>, <a href="IfEqual.htm">If</a>, <a href="../misc/Arrays.htm">Arrays</a></p>
<h3>Example</h3>
<pre class="NoIndent">Var1 = This is a string.
Color2 = 450
Color3 = %Var1%
Array%i% = %A_TICKCOUNT%</pre>

</body>
</html>
